package com.lanan.springboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lanan.springboot.mapper.DataMapper;
import com.lanan.springboot.model.Data;
import com.lanan.springboot.model.Tag;
import com.lanan.springboot.service.IDataService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LanAn
 * @date 2022/4/16-22:01
 * @Description DataService
 */
@Service
@Transactional
public class DataService implements IDataService {

    @Resource
    DataMapper dataMapper;

    @Override
    public Data selectById(Integer id) {
        return dataMapper.selectById(id);
    }

    @Override
    public Data selectByName(String name) {
        QueryWrapper<Data> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(Data::getName, name);
        return dataMapper.selectOne(wrapper);
    }

    @Override
    public List<Data> selectByIds(List<Integer> ids) {
        QueryWrapper<Data> wrapper = new QueryWrapper<>();
        wrapper.lambda().in(Data::getId, ids);
        return dataMapper.selectList(wrapper);
    }

    /**
     * @param data
     * @return java.util.List<com.lanan.springboot.model.Data>
     * @desc 保存资料
     * @author lanan
     * @date 2022-04-16 21:58:49
     **/
    @Override
    public List<Data> insertTag(String data) {
        return null;
    }

    /**
     * @param pageNo
     * @param pageSize
     * @param name
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.lanan.springboot.model.Data>
     * @desc 查询资料列表
     * @author lanan
     * @date 2022-04-16 21:56:24
     **/
    @Override
    public IPage<Data> selectAll(Integer pageNo, Integer pageSize, String name) {
        return null;
    }

    @Override
    public void update(Data data) {

    }

    /**
     * @param id
     * @return void
     * @desc 删除资料
     * @author lanan
     * @date 2022-04-16 21:56:31
     **/
    @Override
    public void delete(Integer id) {

    }

    /**
     * @return int
     * @desc 查询今天新增的资料数
     * @author lanan
     * @date 2022-04-16 21:56:44
     **/
    @Override
    public int countToday() {
        return 0;
    }
}
